home *** CD-ROM | disk | FTP | other *** search
/ Ray Dream Studio 5 / Ray Dream.iso / pc / DreamSDK / Windows / SAMPLES / SCENEOP / SCOP / COMSCOP.CPP next >
Encoding:
C/C++ Source or Header  |  1997-07-11  |  4.3 KB  |  158 lines

  1. /* $Id: COMScop.cpp 1.6 1997/05/12 19:13:54 damien Exp $ */
  2.  
  3. ////////////////////////////////////////////////////////////////////////
  4. //   Scene Operation : stairs                                         //
  5. //--------------------------------------------------------------------//
  6. //   Implementation of the Scene Operation Interface                  //
  7. //////////////////////////////////////////////////////////////////////// 
  8.  
  9.  
  10. #ifndef __COM_SCOP__
  11. #include "COMScOp.h"
  12. #endif
  13.  
  14. #ifndef __SCOP_DLL__
  15. #include "ScOpDLL.h"
  16. #endif
  17.  
  18. #ifndef __I3DSHSCN__
  19. #include "I3DShScn.h"
  20. #endif
  21.  
  22. #ifndef __3DCOFAIL__
  23. #include "3DCoFail.h"
  24. #endif
  25.  
  26. #ifndef __I3DSHTRE__
  27. #include "I3DShTre.h"
  28. #endif
  29.  
  30. #undef INTERFACE
  31. #define INTERFACE SceneOp
  32. // Constructor / Destructor of the C++ Object :
  33. SceneOp::SceneOp() {
  34.   fCRef=0; // Reference Counter
  35.   // Data initialisation :
  36.   fData.fNbStep = 10;
  37.   fData.fDx = 0.0;
  38.   fData.fDy = 1.0;
  39.   fData.fDz = 1.0;
  40.   }
  41.   
  42. SceneOp::~SceneOp() {
  43.   global_count_Obj--; 
  44.   }
  45.   
  46. // IUnknown Interface :
  47. HRESULT SceneOp::QueryInterface(THIS_ REFIID riid,LPVOID* ppvObj) {
  48.   *ppvObj=NULL;
  49.   
  50.   // The Behavior knows the interfaces of the parent Objects
  51.   if (IsEqualIID(riid, IID_IUnknown))
  52.     *ppvObj=(LPVOID)this;
  53.   else if (IsEqualIID(riid, IID_I3DExSceneOperation))
  54.     *ppvObj=(LPVOID)this;
  55.   else if (IsEqualIID(riid, IID_I3DExDataExchanger))
  56.     *ppvObj=(LPVOID)this;
  57.   else if (IsEqualIID(riid, IID_I3DExtension))
  58.     *ppvObj=(LPVOID)this;
  59.     
  60.   // we must add reference if we return an interface
  61.   if (*ppvObj!=NULL) {
  62.     ((LPUNKNOWN)*ppvObj)->AddRef();
  63.     return NOERROR;
  64.     }
  65.   else {
  66.     return ResultFromScode(E_NOINTERFACE);
  67.     }
  68.   }
  69.  
  70. ULONG SceneOp::AddRef(THIS) {
  71.   return fCRef++;
  72.   }
  73.   
  74. ULONG SceneOp::Release(THIS) {
  75.   ULONG UnreleaseObject=fCRef--;
  76.   
  77.   if (fCRef==0)
  78.      delete this; // No reference left, so destroy the object
  79.   
  80.   return UnreleaseObject;
  81.   // local variable used, because fCRef can be destroyed before.
  82.   }
  83.   
  84. // I3DExtension methods :
  85. I3DExtension* SceneOp::Clone(THIS) {
  86.   SceneOp* theClone = new SceneOp;
  87.   if (theClone) {
  88.     theClone->AddRef();
  89.     theClone->fData=fData; // copy the BehaviorData
  90.     }                               
  91.   return theClone;
  92.   }   
  93.  
  94. HRESULT SceneOp::ShellUtilitiesInit(THIS_ IShUtilities* shellUtilities) {
  95.   InitCoFailure(shellUtilities);
  96.   return NOERROR;
  97.   }
  98.  
  99. // I3DExDataExchanger methods :
  100. ExtensionDataMap* SceneOp::GetExtensionDataMap(THIS) {
  101.   return NULL;
  102.   }
  103.  
  104. void* SceneOp::GetExtensionDataBuffer(THIS) {
  105.   return &fData; // used by the shell to set the new parameters
  106.   }
  107.   
  108. HRESULT SceneOp::ExtensionDataChanged(THIS) {
  109.   return NOERROR;
  110.   }
  111.  
  112. HRESULT SceneOp::HandleEvent(THIS_ ULONG SourceID) {
  113.   return ResultFromScode(E_NOTIMPL);
  114.   }
  115.  
  116. short SceneOp::GetResID(THIS) {
  117.   return 150; // this is the view ID in the resource file.
  118.   }
  119.                                                                             
  120. // I3DExSceneOperation methods :
  121. HRESULT SceneOp::Prepare(THIS_ I3DShScene *scene, I3DShTreeElement *tree, I3DShSelection* selection, long index, long total) {
  122.   return NOERROR;
  123.   }
  124.  
  125. Boolean SceneOp::DoIt(THIS_  I3DShScene *scene, I3DShTreeElement *tree, I3DShSelection* selection, long index, long total) {
  126.   I3DShTreeElement *newStep;
  127.   TREETRANSFORM3D stepTransform;
  128.   short iStep;
  129.   
  130.   if (!tree) return FALSE;
  131.   
  132.   for (iStep=0;iStep<fData.fNbStep;iStep++) { 
  133.     newStep = tree->Clone(TRUE);
  134.     if (!newStep) return FALSE;
  135.     tree->InsertRight(newStep);
  136.     newStep->GetGlobalTransform(&stepTransform);
  137.     stepTransform.fT[0]+=((NUM3D)iStep)*fData.fDx;
  138.     stepTransform.fT[1]+=((NUM3D)iStep)*fData.fDy;
  139.     stepTransform.fT[2]+=((NUM3D)iStep)*fData.fDz;
  140.     newStep->SetGlobalTransform(&stepTransform);
  141.   }
  142.  
  143.   return TRUE;
  144.   }
  145.  
  146. HRESULT SceneOp::Prepare8(THIS_ I3DShScene* scene, I3DShTreeElement* tree, I3DShSelection* selection, long index, long total, Boolean* canUndo) {
  147.     *canUndo=false;
  148.     return S_OK;
  149.     }
  150.  
  151. Boolean SceneOp::UndoIt(THIS_ I3DShScene* scene, I3DShTreeElement* tree, I3DShSelection* selection, long index, long total) {
  152.   return false;
  153.     }
  154.  
  155. Boolean SceneOp::RedoIt(THIS_ I3DShScene* scene, I3DShTreeElement* tree, I3DShSelection* selection, long index, long total) {
  156.   return false;
  157.     }
  158.